/**
 * 滑动窗口（同向双指针）-》单调性
 */
class Solution {
    public int minSubArrayLen(int target, int[] nums) {
        int left = 0;
        int right = 0;
        int sum = nums[0];
        int len = Integer.MAX_VALUE;
        while (right < nums.length && left <= right) {
            if (sum < target) {
                right++;
                if(right < nums.length) {//
                    sum += nums[right];
                }
            } else {
                int lenCur = right - left + 1;
                len = Math.min(lenCur,len);
                left++;
                sum -= nums[left - 1];
            }
        }
        return len == Integer.MAX_VALUE ? 0 : len;
    }
}